<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  const getRandomNum = function (min, max, countNum) {
    var arr = [];
    // 在此处补全代码
    for (i = 0; i < countNum; i++) {
      let dex = Math.floor(Math.random() * (max - min) + min)
      //indexof方法判断数组中是否存在该元素 没有返回-1
      //有就返回该元素的索引
      if (arr.indexOf = -1) {
        arr.push(dex)
      }

      console.log(arr.indexOf);

    }
    return arr;
  }
  
  var testArr = getRandomNum(1, 30, 3);
  document.write("<h1>1-30 以内的 3 个随机不重复的整数：" + testArr + "</h1>");

</script>

</html>